﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using POSSystem.DAL;

namespace POSSystem.BLL
{
    public class PurchaseOrderDetails :_PurchaseOrderDetails
    {
        public PurchaseOrderDetails()
        {
        }
        public const String strTotalCost = "TotalCost";

        public void AddInfo(int purchaseOrderID, int productID, string IMEI, string description, int quantity, Decimal unitPrice, Decimal gst)
        {
            this.PurchaseOrderID = purchaseOrderID;
            this.ProductID = productID;
            if(!String.IsNullOrEmpty(IMEI))
                this.IMEI = IMEI;
            if (!String.IsNullOrEmpty(description))
                this.Description = description;
            this.Quantity = quantity;
            this.UnitPrice = unitPrice;
            this.GST = gst;
            this.Deleted = false;
        }

        public void AddInfoPlus(int purchaseOrderID, int productID, string IMEI, string description, int quantity, Decimal unitPrice, Decimal gst)
        {
            this.PurchaseOrderID = purchaseOrderID;
            this.ProductID = productID;
            if (!String.IsNullOrEmpty(IMEI))
                this.IMEI = IMEI;
            if (!String.IsNullOrEmpty(description))
                this.Description = description;
            this.UnitPrice = unitPrice;
            this.GST = gst;
            this.Quantity = quantity;
            if (this.DataTable.Columns[strTotalCost] == null)
                this.AddColumn(strTotalCost, typeof(Decimal));
            this.Deleted = false;    
            this.SetColumn(strTotalCost, UnitPrice * Quantity);
        }

        //only use when addInfoPlus
        public Decimal TotalCost
        {
            get { return (Decimal)this.GetColumn(strTotalCost);}
            set {
                this.SetColumn(strTotalCost, value); 
            }
        }
    }
}
